home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 3.iso / dist / fw_vim.idb / usr / freeware / share / vim / doc / gui.txt.z / gui.txt
Encoding:
Text File  |  1998-10-28  |  18.0 KB  |  446 lines

  1. *gui.txt*       For Vim version 5.0.  Last modification: 1998 Jan 28
  2.  
  3.  
  4.           VIM REFERENCE MANUAL    by Bram Moolenaar
  5.  
  6.  
  7. Vim's Graphical User Interface                *gui* *GUI*
  8.  
  9. 1. Starting the GUI        |gui-start|
  10. 2. Scrollbars            |gui-scrollbars|
  11. 3. Mouse Control        |gui-mouse|
  12. 4. Making GUI Selections    |gui-selections|
  13. 5. Menus            |gui-menus|
  14. 6. Extras            |gui-extras|
  15. 7. Shell Commands        |gui-shell|
  16.  
  17. Other GUI documentation:
  18. |gui_x11.txt|    For specific items of the X11 GUI.
  19. |gui_w32.txt|    For specific items of the Win32 GUI.
  20.  
  21. {Vi does not have any of these commands}
  22.  
  23. ==============================================================================
  24. 1. Starting the GUI                    *gui-start*
  25.  
  26. First you must make sure you actually have a version of Vim with the GUI code
  27. included.  You can check this with the ":version" command, it should include
  28. "+GUI_Motif", "+GUI_Athena" or "+GUI_win32".
  29.  
  30. How to start the GUI depends on the system used.  Mostly you can can run the
  31. GUI version of Vim with:
  32.     gvim [options] [files...]
  33.  
  34. The X11 version of Vim can run both in GUI and in non-GUI mode.  See
  35. |gui-x11-start|.
  36.  
  37.                     *gui-init* *gvimrc* *.gvimrc* *_gvimrc*
  38. When the GUI starts up initializations are carried out, in this order:
  39. - If the system menu file exists, it is sourced.  The name of this file is
  40.   normally "$VIM/menu.vim".  You can check this with ":version".  Also
  41.   see |$VIM|.
  42. - If the "-U {gvimrc}" command line option has been used when starting Vim,
  43.   the {gvimrc} file will be read for initializations.  The following
  44.   initializations are skipped.
  45. - For Unix, if the system gvimrc exists, it is sourced.  The name of this file
  46.   is normally "$VIM/gvimrc".  You can check this with ":version".  Also see
  47.   |$VIM|.
  48. - The following are tried, and only the first one that exists is used:
  49.   - If the GVIMINIT environment variable exists and is not empty, it is
  50.     executed as an Ex command.
  51.   - If the user gvimrc file exists, it is sourced.  The name of this file is
  52.     normally "$HOME/.gvimrc".  You can check this with ":version".
  53.   - For Win32, when $HOME is not set, "$VIM\_gvimrc" is used.
  54.   - When a "_gvimrc" file is not found, ".gvimrc" is tried too.  And vise
  55.     versa.
  56. - If the 'exrc' option is set (which is NOT the default) the file ./.gvimrc
  57.   is sourced, if it exists and isn't the same file as the system or user
  58.   gvimrc file.  If this file is not owned by you, some security restrictions
  59.   apply.
  60.  
  61. NOTE: All but the first one are not carried out if Vim was started with
  62. "-u NONE" and no "-U" argument was given, or when started with "-U NONE".
  63.  
  64. All this happens AFTER the normal Vim initializations, like reading your
  65. .vimrc file.  See |initialization|.
  66.  
  67. You can use the gvimrc files to set up your own customised menus (see |:menu|)
  68. and initialise other things that you may want to set up differently from the
  69. terminal version.
  70.  
  71. There are a number of options which only have meaning in the GUI version of
  72. Vim.  These are 'guicursor', 'guifont', 'guipty' and 'guioptions'.  They are
  73. documented in |options.txt| with all the other options.
  74.  
  75. If using the Motif or Athena version of the GUI (not for the Win32 version), a
  76. number of X resources are available.  See |gui-resources|.
  77.  
  78. Another way to set the colors for different occasions is with highlight
  79. groups.  The "Normal" group is used to set the background and foreground
  80. colors.  Example (which looks nice):
  81.  
  82. >    :highlight Normal guibg=grey90
  83.  
  84. The "guibg" and "guifg" settings ovverride the normal background and
  85. foreground settings.  The other settings for the Normal highlight group are
  86. not used.  Use the 'guifont' option to set the font.
  87.  
  88. Also check out the 'guicursor' option, to set the colors for the cursor in
  89. various modes.
  90.  
  91. ==============================================================================
  92. 2. Scrollbars                        *gui-scrollbars*
  93.  
  94. There are vertical scrollbars and a horizontal scrollbars.  You may
  95. configure which ones appear with the 'guioptions' option.
  96.  
  97. The interface looks like this (with ":set guioptions=mlrb"):
  98.  
  99.                +------------------------------+
  100.                | File  Edit              Help | <- Menu bar (m)
  101.                +-+--------------------------+-+
  102.                |^|                          |^|
  103.                |#| Text area.               |#|
  104.                | |                          | |
  105.                |v|__________________________|v|
  106.  Normal status line -> |-+ File.c              5,2  +-|
  107.  between Vim windows   |^|""""""""""""""""""""""""""|^|
  108.                | |                          | |
  109.                | | Another file buffer.     | |
  110.                | |                          | |
  111.                |#|                          |#|
  112.  Left scrollbar (l) -> |#|                          |#| <- Right
  113.                |#|                          |#|    scrollbar (r)
  114.                | |                          | |
  115.                |v|                          |v|
  116.                +-+--------------------------+-+
  117.                | |< ####                   >| | <- Bottom
  118.                +-+--------------------------+-+    scrollbar (b)
  119.  
  120. Any of the scrollbar or menu components may be turned off by not putting the
  121. appropriate letter in the 'guioptions' string.  The bottom scrollbar is
  122. only useful when 'nowrap' is set.
  123.  
  124.  
  125. Vertical Scrollbars                    *gui-vert-scroll*
  126.  
  127. Each Vim window has a scrollbar next to it which may be scrolled up and down
  128. to move through the text in that buffer.  The size of the scrollbar-thumb
  129. indicates the fraction of the buffer which can be seen in the window.
  130. When the scrollbar is dragged all the way down, the last line of the file
  131. will appear in the top of the window.
  132.  
  133.  
  134. Horizontal Scrollbars                    *gui-horiz-scroll*
  135.  
  136. The horizontal scrollbar (at the bottom of the Vim GUI) may be used to
  137. scroll text sideways when the 'wrap' option is turned off.  The
  138. scrollbar-thumb size is such that the text of the current cursor line may be
  139. scrolled as far as possible left and right.
  140.  
  141. ==============================================================================
  142. 3. Mouse Control                    *gui-mouse*
  143.  
  144. The mouse only works if the appropriate flag in the 'mouse' option is set.
  145. When the GUI is switched on the 'mouse' option is set to "a", enabling it for
  146. all modes except for the |hit-return| prompt.  This can be changed in the
  147. "gvimrc" file.
  148.  
  149.  
  150. 3.1 Moving Cursor with Mouse                *gui-mouse-move*
  151.  
  152. Click the left mouse button where you want the cursor to go, and it does!
  153. This works in Normal mode (if 'mouse' contains 'n' or 'a'), Visual mode (if
  154. 'mouse' contains 'v' or 'a') and Insert mode (if 'mouse' contains 'i' or
  155. 'a'), if you click the mouse somewhere in a text buffer. You may use this
  156. with an operator such as 'd' to delete text from the current cursor position
  157. to the position you point to with the mouse.  That is, you hit 'd' and then
  158. click the mouse somewhere.  If you are on the ':' line (or '/' or '?'), then
  159. clicking the left or right mouse button will position the cursor on the ':'
  160. line (if 'mouse' contains 'c' or 'a').  In any situation the middle mouse
  161. button may be clicked to paste the current selection.
  162.  
  163.  
  164. 3.2 Visual Selection with Mouse                *gui-mouse-select*
  165.  
  166. The right mouse button may be clicked somewhere to extend the visual
  167. selection to the position pointed to with the mouse.  If already in Visual
  168. mode then the closest end will be extended, otherwise Visual mode is started
  169. and extends from the old cursor position to the new one.
  170.  
  171. Double clicking may be done to make the selection word-wise, triple clicking
  172. makes it line-wise, and quadruple clicking makes it rectangular block-wise.
  173.  
  174. In the X11 GUI, Visual selection, however it is invoked, makes Vim the owner
  175. of the windowing system's primary selection, so that the highlighted text may
  176. be pasted into other windows.  Similarly, selected text from other windows may
  177. be pasted into Vim in Normal mode, Insert mode, or on the ':' line by clicking
  178. the middle mouse button.
  179.  
  180. In the Win32 GUI, Visually selected text is only copied to the clipboard when
  181. using a "y" command, or another operator when the '*' register is used.
  182.  
  183.  
  184. 3.3 Other Text Selection with Mouse        *gui-mouse-xterm-like*
  185.  
  186. When in Command-line mode, at the |hit-return| prompt or whenever the current
  187. mode is not in the 'mouse' option, a different kind of selection is used.
  188. It is more like what happens in an xterm.  Let's call this xterm-like
  189. selection.  Any text in the Vim window can be selected.  Select the text by
  190. pressing the left mouse button at the start, drag to the end and release.
  191. Right mouse button extends the selection.  Middle mouse button pasts the
  192. text.
  193.  
  194.  
  195. 3.4 Using Mouse on Status Lines                *gui-mouse-status*
  196.  
  197. Clicking the left or right mouse button on the status line below a Vim
  198. window makes that window the current window.  The mouse may then be dragged
  199. up and down to move the status line, thus resizing the windows above and
  200. below it.
  201.  
  202.  
  203. 3.5 Various Mouse Clicks                *gui-mouse-various*
  204.  
  205.     <S-LeftMouse>    Search forward for the word under the mouse click.
  206.     <S-RightMouse>    Search backward for the word under the mouse click.
  207.     <C-LeftMouse>    Jump to the tag name under the mouse click.
  208.     <C-RightMouse>    Jump back to position before the previous tag jump
  209.             (same as "CTRL-T")
  210.  
  211.  
  212. 3.6 Mouse Mappings                    *gui-mouse-mapping*
  213.  
  214. The mouse events, complete with modifiers, may be mapped.  Eg:
  215. >   :map <S-LeftMouse>     <RightMouse>
  216. >   :map <S-LeftDrag>      <RightDrag>
  217. >   :map <S-LeftRelease>   <RightRelease>
  218. >   :map <2-S-LeftMouse>   <2-RightMouse>
  219. >   :map <2-S-LeftDrag>    <2-RightDrag>
  220. >   :map <2-S-LeftRelease> <2-RightRelease>
  221. >   :map <3-S-LeftMouse>   <3-RightMouse>
  222. >   :map <3-S-LeftDrag>    <3-RightDrag>
  223. >   :map <3-S-LeftRelease> <3-RightRelease>
  224. >   :map <4-S-LeftMouse>   <4-RightMouse>
  225. >   :map <4-S-LeftDrag>    <4-RightDrag>
  226. >   :map <4-S-LeftRelease> <4-RightRelease>
  227. These mappings make selection work the way it probably should in a Motif
  228. application, with shift-left mouse allowing for extending the visual area
  229. rather than the right mouse button.
  230.  
  231. Mouse mapping with modifiers does not work for xterm-like selection.
  232.  
  233. ==============================================================================
  234. 4. Making GUI Selections                *gui-selections*
  235.  
  236.                             *quotestar*
  237. You may make selections with the mouse (see |gui-mouse-select|), or by using
  238. Vim's Visual mode (see |v|).  If 'a' is present in 'guioptions', then
  239. whenever Visual mode is invoked, or when the cursor moves while in Visual
  240. mode, Vim becomes the owner of the windowing system's primary selection (on
  241. MS-Windows the |gui-clipboard| is used).
  242.  
  243. There is a special register for storing this selection, it is the <"*>
  244. register.  Nothing is put in here unless the information about what text is
  245. selected is about to change (eg with a left mouse click somewhere), or when
  246. another application wants to paste the selected text.  Then the text is put
  247. in the <"*> register.  For example, to cut a line and make it the current
  248. selection/put it on the clipboard:
  249. >    "*dd
  250.  
  251. Similarly, when you want to paste a selection from another application, e.g.,
  252. by clicking the middle mouse button, the selection is put in the <"*> register
  253. first, and then 'put' like any other register.  For example, to put the
  254. selection (contents of the clipboard):
  255. >    "*p
  256.  
  257. Note that when pasting text from one Vim into another separate Vim, the type
  258. of selection (character, line, or block) will also be copied.
  259.  
  260. ==============================================================================
  261. 5. Menus                        *gui-menus*
  262.  
  263. 5.1 Using Menus                        *gui-using-menus*
  264.  
  265. The default menus are quite simple at the moment.  Power Vim users won't use
  266. them much.  But the power is in adding your own menus and menu items.  They
  267. are most useful for things that you can't remember what the key sequence
  268. was.
  269.  
  270. Eventually I would like to expand the set of default menus to use pop up and
  271. other windows for confirmation, file selection etc.  Maybe have a dialogue
  272. box for browsing and choosing buffers, etc.
  273.  
  274. Motif supports Tear-off menus.  These are sort of sticky menus or pop-up
  275. menus that are present all the time.  If the resizing does not work
  276. correctly, this may be caused by using something like "Vim*geometry" in de
  277. defaults.  Use "Vim.geometry" instead.
  278.  
  279.                             *menu.vim*
  280. The default menus are read from the file "$VIM/menu.vim".  See |$VIM| for
  281. where the path comes from.  You can set up your own menus.  Starting off with
  282. the default set is a good idea.  You can add more items, or, if you don't like
  283. the defaults at all, start with removing all menus |:unmenu-all|.
  284.  
  285.  
  286. 5.2 Creating New Menus                    *gui-creating-menus*
  287.  
  288.                 *:me*  *:menu*  *:noreme*  *:noremenu*
  289.                 *:am*  *:amenu* *:an*      *:anoremenu*
  290.                 *:nme* *:nmenu* *:nnoreme* *:nnoremenu*
  291.                 *:ome* *:omenu* *:onoreme* *:onoremenu*
  292.                 *:vme* *:vmenu* *:vnoreme* *:vnoremenu*
  293.                 *:ime* *:imenu* *:inoreme* *:inoremenu*
  294.                 *:cme* *:cmenu* *:cnoreme* *:cnoremenu*
  295. To create a new menu item, use the ":menu" commands.  They are exactly like
  296. the ":map" set of commands but the first argument is a menu item name, given
  297. as a path of menus and submenus with a '.' between them. eg:
  298. >   :menu File.Save  :w^M
  299. >   :inoremenu File.Save  ^O:w^M
  300. >   :menu Edit.Big\ Changes.Delete\ All\ Spaces  :%s/[ ^I]//g^M
  301.  
  302. This last one will create a new item in the menu bar called "Edit", holding
  303. the mouse button down on this will pop up a menu containing the item
  304. "Big Changes", which is a sub-menu containing the item "Delete All Spaces",
  305. which when selected, performs the operation.
  306.  
  307. The ":amenu" command can be used to define menu entries for all modes at once.
  308. To make the command work correctly, a character is automatically inserted for
  309. some modes:
  310.     mode        inserted    ~
  311.     Normal        nothing
  312.     Visual        <Esc>
  313.     Insert        <C-O>
  314.     Cmdline        <C-C>
  315.     Op-pending    <Esc>
  316.  
  317. Example:
  318. >   :amenu File.Exit    :qa!^M
  319. is equal to:
  320. >   :nmenu File.Exit    :qa!^M
  321. >   :vmenu File.Exit    ^[:qa!^M
  322. >   :imenu File.Exit    ^O:qa!^M
  323. >   :cmenu File.Exit    ^C:qa!^M
  324. >   :omenu File.Exit    ^[:qa!^M
  325.  
  326. Careful: In Insert mode this only works for a SINGLE Normal mode command,
  327. because of the CTRL-O.  If you have two or more commands, you will need to use
  328. the ":imenu" command.  For inserting text in any mode, you can use the
  329. expression register:
  330. >   :amenu Insert.foobar   "='foobar'<CR>P
  331.  
  332. Note that the '<' and 'k' flags in 'cpoptions' also apply here (when
  333. included they make the <> form and raw key codes not being recognized).
  334.  
  335. Note that <Esc> in Cmdline mode executes the command, like in a mapping.  This
  336. is Vi compatible.  Use CTRL-C to quit Cmdline mode.
  337.  
  338.                             *menu-priority*
  339. You can give a priority to a menu.  Menus with a higher priority go more to
  340. the right.  The priority is given as a number before the ":menu" command.
  341. Example:
  342. >    :70menu Buffer.next :bn<CR>
  343.  
  344. The default menus have these priorities:
  345.     File    10
  346.     Edit    20
  347.     Syntax    50
  348.     Help    9999
  349.  
  350. When no priority is given, 500 is used.
  351.  
  352. You can use a priority higher than 9999, to make it go after the Help menu,
  353. but that is non-standard and is discouraged.  The highest possible priority is
  354. about 32000.
  355.  
  356. Currently, you can only give a priority for the location of the menu in the
  357. menu bar, not for the location of a menu item in a menu.
  358.  
  359.  
  360. 5.3 Showing What Menus Are Mapped To            *gui-showing-menus*
  361.  
  362. To see what an existing menu is mapped to, use just one argument after the
  363. menu commands (just like you would with the ":map" commands).  If the menu
  364. specified is a submenu, then all menus under that hierarchy will be shown.
  365. If no argument is given after :menu at all, then ALL menu items are shown
  366. for the appropriate mode (eg, Command-line mode for :cmenu).
  367.  
  368. Note that hitting <Tab> while entering a menu name after a menu command may
  369. be used to complete the name of the menu item.
  370.  
  371.  
  372. 5.4 Deleting Menus                    *gui-delete-menus*
  373.  
  374.                         *:unme*  *:unmenu*
  375.                         *:aun*   *:aunmenu*
  376.                         *:nunme* *:nunmenu*
  377.                         *:ounme* *:ounmenu*
  378.                         *:vunme* *:vunmenu*
  379.                         *:iunme* *:iunmenu*
  380.                         *:cunme* *:cunmenu*
  381. To delete a menu item or a whole submenu, use the unmenu commands, which are
  382. analogous to the unmap commands.  Eg:
  383.     :unmenu! Edit.Paste
  384.  
  385. This will remove the Paste item from the Edit menu for Insert and
  386. Command-line modes.
  387.  
  388. Note that hitting <Tab> while entering a menu name after an umenu command
  389. may be used to complete the name of the menu item for the appropriate mode.
  390.  
  391. To remove all menus use:            *:unmenu-all*
  392. >    :unmenu *    " remove all menus in Normal and visual mode
  393. >    :unmenu! *    " remove all menus in Insert and Command-line mode
  394.  
  395.  
  396. 5.5 Examples for Menus
  397.  
  398. Here is an example on how to add menu items with menu's!  You can add a menu
  399. item for the keyword under the cursor.  The register "z" is used.
  400.  
  401. >  :nmenu Words.Add\ Var      wb"zye:menu! Words.<C-R>z <C-R>z<CR>
  402. >  :nmenu Words.Remove\ Var      wb"zye:unmenu! Words.<C-R>z<CR>
  403. >  :vmenu Words.Add\ Var    "zy:menu! Words.<C-R>z <C-R>z <CR>
  404. >  :vmenu Words.Remove\ Var      "zy:unmenu! Words.<C-R>z<CR>
  405. >  :imenu Words.Add\ Var    <Esc>wb"zye:menu! Words.<C-R>z <C-R>z<CR>a
  406. >  :imenu Words.Remove\ Var      <Esc>wb"zye:unmenu! Words.<C-R>z<CR>a
  407.  
  408. (the rhs is in <> notation, you can copy/paste this text to try out the
  409. mappings, or put these lines in your gvimrc; "<C-R>" is CTRL-R, "<CR>" is
  410. the <CR> key.  |<>|)
  411.  
  412. ==============================================================================
  413. 6. Extras                        *gui-extras*
  414.  
  415. This section describes other features which are related to the GUI.
  416.  
  417. - With the GUI, there is no wait for one second after hitting escape, because
  418.   the key codes don't start with <Esc>.
  419.  
  420. - Typing ^V followed by a special key in the GUI will insert "<Key>", since
  421.   the internal string used is meaningless.  Modifiers may also be held down to
  422.   get "<Modifiers-Key>".
  423.  
  424. - In the GUI, the modifiers SHIFT, CTRL, and ALT (or META) may be used within
  425.   mappings of special keys and mouse events.  eg: :map <M-LeftDrag> <LeftDrag>
  426.  
  427. - In the GUI, several normal keys may have modifiers in mappings etc, these
  428.   are <Space>, <Tab>, <NL>, <CR>, <Esc>.
  429.  
  430. ==============================================================================
  431. 7. Shell Commands                    *gui-shell*
  432.  
  433. WARNING: Executing an external command from the GUI will not always work.
  434. "normal" commands like "ls", "grep" and "make" mostly work fine.  Commands
  435. that require an intelligent terminal like "less" and "ispell" won't work.
  436. Some may even hang and need to be killed from another terminal.  So be
  437. careful!
  438.  
  439. For the X11 GUI the external commands are executed inside the gvim window.
  440. See |gui-pty|.
  441.  
  442. For the Win32 GUI the external commands are executed in a separate window.
  443. See |gui-shell-win32|.
  444.  
  445.  vim:tw=78:ts=8:sw=4
  446.